const Koa = require("koa");
const duration = require("./middleware/duration");
const header = require("./middleware/header");
const data = require("./middleware/data");
const app = new Koa();
const APP_PORT = 3000;
const webSocket = require("./service/webSocket");
const cors = require('koa2-cors');

// 允许所有域名的跨域请求
app.use(cors());

app.use(duration);
app.use(header);
app.use(data);

app.listen(APP_PORT, () => {
  console.log(
    "\n\x1B[34mserver is running on \x1B[0m%s",
    `http://localhost:${APP_PORT}`
  );
});

webSocket.listen();
